using System.Collections.Generic;
using FlowCanvas.Nodes;
using Yoozoo.Gameplay.Liberty.AI;
using Yoozoo.Gameplay.Liberty.StreetEvent;

namespace com.yoozoo.gta.Gameplay.Liberty.StreetEvent.BpNode
{
    public class PausePartOfMonsterAi: CallableActionNode<bool>
    {
        public List<int> MonsterIdList;
        public override void Invoke(bool isPause)
        {

            if (MonsterIdList!=null)
            {
                Dictionary<int, StreetEventMonsterData> monsterId2InfoMap = StreetEventManager.GetInstance().monsterId2InfoMap;

                foreach (var streetId in MonsterIdList)
                {
                    foreach (var data in monsterId2InfoMap.Values)
                    {
                        if (data.streetNpcId == streetId)
                        {
                            var aiEntity = LibertyAIUtils.AIManager.NpcBirthManager.GetNpc(data.uniqueId);
                            if (aiEntity != null)
                            {
                                if (isPause && aiEntity.graph.gameObject.activeSelf)
                                {
                                    aiEntity.graph.gameObject.SetActive(false);
                                }
                                else if (!isPause && !aiEntity.graph.gameObject.activeSelf)
                                {
                                    aiEntity.graph.gameObject.SetActive(true);
                                }
                            }
                        }
                    }
                   
                }
            }
        }
    }
}